﻿using SheepStorage.Domain.Entity;
using SheepStorage.Repository.Interface;
using SheepStorage.Service.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SheepStorage.Service.DataImp
{
    /// <summary>
    /// 地方服务实现
    /// </summary>
    public class PlaceService : IPlaceService
    {
        /// <summary>
        /// 地方仓储
        /// </summary>

        private readonly IBaseRepository<Place> repository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="repository">地方仓储</param>
        public PlaceService(IBaseRepository<Place> repository)
        {
            this.repository = repository;
        }

        /// <summary>
        /// 显示地方
        /// </summary>
        /// <param name="AreaId"></param>
        /// <returns></returns>
        public async Task<List<Place>> GetPlace(int AreaId)
        {
            var list = repository.GetAll().ToList();
            if (AreaId > 0)
            {
                list = list.Where(C => C.AreaId == AreaId).ToList();
            }
            return list;
        }
    }
}
